<!doctype html>
<html lang="zh">
<head>
    <meta charset="UTF-8" />
    <link rel="icon" href="/favicon.ico" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>后台管理系统</title>
    <script>
        // 确保页面在加载前就显示加载动画
        document.documentElement.style.backgroundColor = '#f5f7fa'
        document.body ? (document.body.style.backgroundColor = '#f5f7fa') : null
    </script>
    <style>
        html,
        body {
            margin: 0;
            padding: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
            overflow: hidden;
        }

        /* 现代化全屏加载样式 */
        #app-loading {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
            z-index: 9999;
            display: flex;
            justify-content: center;
            align-items: center;
            transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
        }

        /* 添加动态背景效果 */
        #app-loading::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background:
                radial-gradient(circle at 20% 80%, rgba(148, 163, 184, 0.1) 0%, transparent 50%), radial-gradient(circle at 80% 20%, rgba(203, 213, 225, 0.2) 0%, transparent 50%),
                radial-gradient(circle at 40% 40%, rgba(148, 163, 184, 0.15) 0%, transparent 50%);
            animation: background-shift 6s ease-in-out infinite;
        }

        .app-loading-wrap {
            position: relative;
            text-align: center;
            z-index: 2;
        }

        /* 现代化几何spinner */
        .app-loading-spinner {
            width: 80px;
            height: 80px;
            margin: 0 auto 40px;
            position: relative;
        }

        .spinner-ring {
            position: absolute;
            width: 100%;
            height: 100%;
            border-radius: 50%;
            animation: spinner-rotate 2s linear infinite;
        }

        .spinner-ring:nth-child(1) {
            border: 3px solid transparent;
            border-top: 3px solid rgba(59, 130, 246, 0.8);
            animation-duration: 1.5s;
        }

        .spinner-ring:nth-child(2) {
            border: 3px solid transparent;
            border-top: 3px solid rgba(99, 102, 241, 0.6);
            animation-duration: 2s;
            animation-direction: reverse;
            width: 60px;
            height: 60px;
            top: 10px;
            left: 10px;
        }

        .spinner-ring:nth-child(3) {
            border: 2px solid transparent;
            border-top: 2px solid rgba(139, 92, 246, 0.4);
            animation-duration: 3s;
            width: 40px;
            height: 40px;
            top: 20px;
            left: 20px;
        }

        /* 脉冲中心点 */
        .spinner-center {
            position: absolute;
            top: 50%;
            left: 50%;
            width: 12px;
            height: 12px;
            background: radial-gradient(circle, rgba(59, 130, 246, 0.9) 0%, rgba(99, 102, 241, 0.4) 100%);
            border-radius: 50%;
            transform: translate(-50%, -50%);
            animation: pulse 1.5s ease-in-out infinite;
        }

        /* 现代化进度条 */
        .app-loading-progress {
            width: 240px;
            height: 4px;
            background: rgba(203, 213, 225, 0.3);
            border-radius: 2px;
            margin: 0 auto;
            overflow: hidden;
            position: relative;
            backdrop-filter: blur(10px);
        }

        .app-loading-progress-bar {
            position: absolute;
            top: 0;
            left: 0;
            height: 100%;
            width: 0;
            background: linear-gradient(90deg, rgba(59, 130, 246, 0.9) 0%, rgba(99, 102, 241, 0.7) 50%, rgba(59, 130, 246, 0.9) 100%);
            animation: progress-flow 2s ease-in-out infinite;
            border-radius: 2px;
            box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
        }

        /* 进度百分比 */
        .app-loading-percentage {
            font-size: 14px;
            font-weight: 500;
            color: rgba(71, 85, 105, 0.8);
            margin-top: 12px;
            opacity: 1;
            text-align: center;
        }

        /* 动画定义 */
        @keyframes background-shift {
            0%,
            100% {
                transform: translateX(0) translateY(0);
            }
            25% {
                transform: translateX(-5px) translateY(-5px);
            }
            50% {
                transform: translateX(5px) translateY(5px);
            }
            75% {
                transform: translateX(-3px) translateY(3px);
            }
        }

        @keyframes spinner-rotate {
            0% {
                transform: rotate(0deg);
            }
            100% {
                transform: rotate(360deg);
            }
        }

        @keyframes pulse {
            0%,
            100% {
                transform: translate(-50%, -50%) scale(1);
                opacity: 1;
            }
            50% {
                transform: translate(-50%, -50%) scale(1.2);
                opacity: 0.7;
            }
        }

        @keyframes fade-up {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        @keyframes progress-flow {
            0% {
                width: 0%;
                opacity: 1;
            }
            50% {
                width: 75%;
                opacity: 0.8;
            }
            100% {
                width: 100%;
                opacity: 1;
            }
        }

        /* 响应式设计 */
        @media (max-width: 768px) {
            .app-loading-spinner {
                width: 60px;
                height: 60px;
            }

            .app-loading-title {
                font-size: 24px;
            }

            .app-loading-progress {
                width: 200px;
            }
        }

        @media (max-width: 480px) {
            .app-loading-spinner {
                width: 50px;
                height: 50px;
            }

            .app-loading-progress {
                width: 160px;
            }
        }
    </style>
</head>
<body>
<!-- 现代化全屏加载 -->
<div id="app-loading">
    <div class="app-loading-wrap">
        <!-- 几何spinner -->
        <div class="app-loading-spinner">
            <div class="spinner-ring"></div>
            <div class="spinner-ring"></div>
            <div class="spinner-ring"></div>
            <div class="spinner-center"></div>
        </div>

        <!-- 进度条 -->
        <div class="app-loading-progress">
            <div class="app-loading-progress-bar"></div>
        </div>
        <div class="app-loading-percentage">0%</div>
    </div>
</div>

<div id="app"></div>
<script>
    // 简单直接的百分比动画
    function startProgressAnimation() {
        let progress = 0
        const percentageElement = document.querySelector('.app-loading-percentage')

        if (!percentageElement) {
            return
        }

        function updateProgress() {
            // 随机增长 1-3%
            progress += Math.random() * 2 + 1

            if (progress >= 100) {
                progress = 100
            }

            percentageElement.textContent = Math.floor(progress) + '%'

            if (progress < 100) {
                setTimeout(updateProgress, 100 + Math.random() * 100)
            }
        }

        updateProgress()
    }

    // 立即启动
    setTimeout(startProgressAnimation, 100)

    // 页面加载完成后隐藏loading
    window.addEventListener('load', function () {
        // 确保至少显示2秒钟，给用户良好的视觉体验
        setTimeout(() => {
            const loadingElement = document.getElementById('app-loading')
            if (loadingElement) {
                loadingElement.style.opacity = '0'
                setTimeout(() => {
                    loadingElement.style.display = 'none'
                }, 600)
            }
        }, 2000)
    })
</script>
<script type="module" src="/src/main.ts"></script>
<script src="./static/config.js"></script>
</body>
</html>
